package com.accloud.activator;

import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import com.accloud.cloudservice.AC;
import com.accloud.cloudservice.ACDeviceActivator;
import com.hiflying.smartlink.OnSmartLinkListener;
import com.hiflying.smartlink.SmartLinkedModule;
import com.hiflying.smartlink.v7.MulticastSmartLinker;

public class HFV8Activator extends ACDeviceActivator {
    private MulticastSmartLinker smartLinker;

    @Override // com.accloud.cloudservice.ACDeviceActivator
    public void startSmartConfig(final String ssid, final String password, int timeout_ms) {
        new Handler(Looper.getMainLooper()).post(new Runnable() {
            /* class com.accloud.activator.HFV8Activator.AnonymousClass1 */

            @Override // java.lang.Runnable
            public void run() {
                try {
                    HFV8Activator.this.smartLinker = MulticastSmartLinker.getInstance();
                    HFV8Activator.this.smartLinker.setMixType(2);
                    HFV8Activator.this.smartLinker.start(AC.context, password, ssid);
                    HFV8Activator.this.smartLinker.setOnSmartLinkListener(new OnSmartLinkListener() {
                        /* class com.accloud.activator.HFV8Activator.AnonymousClass1.AnonymousClass1 */

                        @Override // com.hiflying.smartlink.OnSmartLinkListener
                        public void onLinked(SmartLinkedModule smartLinkedModule) {
                            Log.d(ACDeviceActivator.TAG, "onLinked ip:" + smartLinkedModule.getIp() + ", MAC:" + smartLinkedModule.getMac());
                        }

                        @Override // com.hiflying.smartlink.OnSmartLinkListener
                        public void onCompleted() {
                            Log.d(ACDeviceActivator.TAG, "onCompleted");
                        }

                        @Override // com.hiflying.smartlink.OnSmartLinkListener
                        public void onTimeOut() {
                            Log.d(ACDeviceActivator.TAG, "onTimeOut");
                        }
                    });
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    @Override // com.accloud.cloudservice.ACDeviceActivator
    public void stopSmartConfig() {
        super.stopSmartConfig();
        if (this.smartLinker != null) {
            this.smartLinker.setOnSmartLinkListener(null);
            this.smartLinker.stop();
        }
    }
}
